package nibian

class GrandFather2(var name:String)
class Father2(name:String) extends GrandFather2(name)
class Son2(name:String) extends  Father2(name)
// 逆变
//class Card2[-T](val name:String, val t :T)
class Card3[-T](val name:String)

object NiBianDemo {
//  def doThings(card:Card2[Son2]): Unit ={
//    println(card.name + "....." + card.t.asInstanceOf[GrandFather2].name )
//  }
  def doThings2(card:Card3[Son2]): Unit ={
    println(card.name + "....." )
  }
  def main(args: Array[String]): Unit = {
    //val card = new Card2[GrandFather2]("card", new GrandFather2("GrandFather2"))
    val card2 = new Card3[GrandFather2]("card")
    doThings2(card2)
  }
}
